package com.gigmissions.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.overlay.GeoXmlLoadCallback;
import com.google.gwt.maps.client.overlay.GeoXmlOverlay;
import com.google.gwt.user.client.Window;

public class KmlGigLoadCallback extends GeoXmlLoadCallback {
	
	private MapWidget map;
	private GeoXmlOverlay geoXml = null;
	
	public KmlGigLoadCallback(MapWidget map,GeoXmlOverlay geoXml){
		
		this.map = map;
		this.geoXml = geoXml;
		
	}
	
	private KmlGigLoadCallback(){
		
		
	}

	@Override
	public void onFailure(String url, Throwable caught) {
		// TODO Auto-generated method stub
		  StringBuffer message = new StringBuffer("KML File " + url
                  + " failed to load");
              if (caught != null) {
                message.append(caught.toString());
              }
              Window.alert(message.toString());

	}

	@Override
	public void onSuccess(String url, GeoXmlOverlay overlay) {
		// TODO Auto-generated method stub
		 geoXml = overlay;
         map.clearOverlays();
         map.addOverlay(geoXml);
         geoXml.gotoDefaultViewport(map);
         GWT.log("KML File " + url + "loaded successfully", null);
         GWT.log("Default Center=" + geoXml.getDefaultCenter(), null);
         GWT.log("Default Span=" + geoXml.getDefaultSpan(), null);
         GWT.log("Default Bounds=" + geoXml.getDefaultBounds(), null);
         GWT.log("Supports hide=" + geoXml.supportsHide(), null);
		

	}

}
